<div style="position: relative;">
<h1 class="pagetitle"><%= link_to 'All Media', :controller => 'media', :action => 'list' %> &raquo; <% unless @media.category.nil? %><%= link_to @media.category.name, :controller => 'media', :action => 'list', :category => @media.category.id, :permalink => @media.category.permalink %> &raquo; <% end %><%= link_to clean_text(@media.title), :controller => 'media', :action => 'show', :id => @media.id, :media_type => @media.media_type, :permalink => @media.permalink %></h1>
<div style="margin-bottom: 5px; padding: 2px; padding-top: 5px; padding-bottom: 5px; position: absolute; right: 0; text-align: center; width: 120px; background: #f0f0f0; border: solid 1px #c0c0c0;" id="rating_<%= @media.id %>">
<%= render(:partial => 'rating') %>
</div>
Author: <%= link_to @media.user.login, :controller => 'account', :action => 'show', :id => @media.user.login %> <%= distance_of_time_in_words_to_now(@media.created_at) %> ago<br />
<% if !@media.deleted_at.nil? %>Deleted: <%= distance_of_time_in_words_to_now(@media.deleted_at) %> ago<% if logged_in? and current_user.has_role?(['Administrator', 'Moderator']) %> ( <%= link_to_component_lightbox 'Show Reason', { :controller => '/media', :action => 'delete_reason', :id => @media.id } %> )<% end %><br /><% end %>

<div class="article">
  <script type="text/javascript">
    //<![CDATA[
      var movie_done = false;
      var image_done = false;
    //]]> 
  </script>
  <% if @media.mediable_type == 'ImageFile' %>
    <div id="imagediv">
      <%= render :partial => "image", :locals => { :media => @media, :secondrun => false } %>
    </div>
  <% elsif @media.mediable_type == 'VideoFile' %>
    <div id="moviediv">
      <%= render :partial => "video", :locals => { :media => @media, :secondrun => false } %>
    </div>
  <% end %>
  <%= format_text(@media.description) %><br />
</div>
Tags: <%= @media.tags.collect{|t| link_to t.name, :controller => '/media', :action => 'search', :tag => t.name}.join(", ") %><br />
This media has been viewed <%= @media.views %> times.<br />
<% if logged_in? and ( current_user.has_role?(['Administrator', 'Moderator']) or ( @media.user.id == current_user.id and @media.deleted_at.nil? )) %>
  ( <%= link_to_component_lightbox 'Edit', { :controller => '/media', :action => 'edit', :id => @media.id } %>
	<% if @media.deleted_at.nil? %> / <%= link_to_component_lightbox 'Delete', { :controller => '/media', :action => 'delete', :id => @media.id } %><% end %>
	<% if current_user.has_role?(['Administrator', 'Moderator']) and !@media.deleted_at.nil? %>
		/ <%= link_to 'Undelete', { :controller => '/media', :action => 'undestroy', :id => @media.id }, :confirm => 'Are you sure?', :method => :post %>
	<% end %>)
<% end %>
<br style="clear: both;" /><br>
<div id="tabs" class="nicetabs">
  <ul>
    <li><a href="#comments">Comments</a></li>
    <li><a href="#newcomment">New Comment</a></li>
  </ul>
</div>
<div id="comments">
  <div class="tabbox">
    <% unless @comments.nil? or @comments.empty? %>
      <% for @comment in @comments %>
        <div style="margin: 0px 0px 0px <%= @comment.depth.to_i * 25 %>px; <% if @comment.rating >= @comment_threshold %>display: block;<% else %>display: none;<% end %>" id="comment<%= @comment.id.to_s %>_visible">
          <div style="background: #f0f0f0; padding:3px; border: solid 1px #bbbbbb;"> 
            <div style="float: left; width: <%= (587 - (@comment.depth.to_i * 25)) %>px;"><a name="comments,<%= @comment.id%>"></a>
              By <%= link_to @comment.user.login, :controller => 'account', :action => 'show', :id => @comment.user.login %> <%= distance_of_time_in_words_to_now(@comment.created_at) %> ago 
              <% if logged_in? and @comment.purged_at.nil? and current_user.has_role?(['Administrator', 'Moderator']) or @comment.user.id == current_user.id %>
                (<% if current_user.has_role?(['Administrator', 'Moderator']) or @comment.user.id == current_user.id %>
        					<%= link_to_component_lightbox 'Edit', { :controller => '/comment', :action => 'edit', :id => @comment.id } %>
        				<% end %>
        				<% if @comment.deleted_at.nil? %>
                  / <%= link_to_component_lightbox 'Delete', { :controller => '/comment', :action => 'delete', :id => @comment.id } %>
        				<% end %>
        				<% if current_user.has_role?(['Administrator', 'Moderator']) and !@comment.deleted_at.nil? %>
        					/ <%= link_to 'Undelete', { :controller => '/comment', :action => 'undestroy', :id => @comment.id }, :confirm => 'Are you sure?', :method => :post %> / <%= link_to_component_lightbox 'Show Reason', { :controller => '/comment', :action => 'delete_reason', :id => @comment.id } %>
        				<% end %>)
              <% end %>
            </div>
            <div style="padding: 2px; float: right; text-align: right; clear: right; width: 120px; background: #f0f0f0;" id="comment_rating_<%= @comment.id %>">
              <%= render(:partial => 'comment/comment_rating') %>
            </div>
            <div style="clear: both;"></div>
          </div>
          <div style="clear: both; padding: 5px;">
            <%= format_text(@comment.text) %>
            <% if @comment.rating < @comment_threshold %>
            This comment is below the rating threshold for comments.  <%= link_to_function "Hide Comment", "Element.toggle('comment"+@comment.id.to_s+"_hidden');Element.toggle('comment"+@comment.id.to_s+"_visible')" %>
            <% end %>
          </div>
          <div style="text-align: right; padding-bottom: 10px;">
              <%= link_to_function 'Reply', "new Ajax.Updater('comment_div', '/comment/reply?media_id="+@media.id.to_s+"&amp;parent_id="+@comment.id.to_s+"', {asynchronous:true, evalScripts:true, onComplete:function(request) {Element.hide('reply_spinner'); Element.show('comment_div');}, onLoading:function(request) {Element.show('reply_spinner'); Element.hide('comment_div');} }); tabs.setActiveTab('newcomment'); return false;" %>
          </div>
        </div>
        <div style="margin: 0px 0px 0px <%= @comment.depth.to_i * 25 %>px; <% if @comment.rating < @comment_threshold %>display: block;<% else %>display: none;<% end %>" id="comment<%= @comment.id %>_hidden">
          <div style="background: #f0f0f0; padding:3px; border: solid 1px #bbbbbb;"> 
            This comment is below the rating threshold for comments.  <%= link_to_function "Show Comment", "Element.toggle('comment"+@comment.id.to_s+"_hidden');Element.toggle('comment"+@comment.id.to_s+"_visible')" %>
          </div>
        </div>
      <% end %>
    <% else %>
      <div><p>There are no comments for this media.</p></div>
    <% end %>
  </div>
</div>
<div id="newcomment" style="display: none;">
  <div class="tabbox">
    <% if logged_in? %>
      <% @comment = nil %>
      <div id="comment_div">
        <div style="padding: 10px;">
        <% form_tag :controller => '/comment', :action => 'add', :id => @media.id do %>
          <%= hidden_field 'comment', 'parent_id', :value=> '0' %>
          <% @form_id = 'new' %>
          <%= render :partial => 'comment/comment_form' %>
          <%= submit_tag "Add Comment" %>
        <% end %>
        </div>
      </div>
      <div style="text-align: center; display: none;" id="reply_spinner">
      <img src="/images/big-spinner.gif" />
      </div>
    <% else %>
      <p>Sorry you must be <%= link_to 'Logged In', :controller => '/account', :action => 'login', :return_to => '/media/show/'+@media.id.to_s %> to comment on media.</p>
    <% end %>
  </div>
</div>
<script type="text/javascript">
  var tabs = new Control.Tabs('tabs');
  <% if (error_messages_for 'comment') != "" %>tabs.setActiveTab('newcomment');<% end %>
</script>
</div>
<div id="controlbar"></div>
